<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="lzy">
    <title>lzy-</title>
    <style>
        html,body{
            height: 100%;
        }
        body{
            margin: 0;
        }
        header{
            margin: 10px auto;
            width: 100%;
            text-align: center;
        }
        span{
            display: inline-block;
            width: 50px;
            height: 20px;
            border: 1px solid black;
            border-radius: 5px;
            font-size: 14px;
            cursor: pointer;
        }
        div{
            width: 200px;
            height: 200px;
            background-color: black;
            margin: 0 auto;
        }
        .t0{
            width: 400px;
        }
        .t1{
            height: 400px;
        }
        .t2{
            background-color: red;
        }
        .t3{
            display: none;
        }
    </style>
</head>
<body>
    <header>
        <span>变宽</span>
        <span>变高</span>
        <span>变色</span>
        <span>隐藏</span>
        <span>重置</span>
    </header>
    <div></div>
</body>
</html>
<script>
    var spans=document.querySelectorAll('span');
    var div = document.querySelector('div');
    for(var i=0;i<spans.length;i++){
        spans[i].index=i;
        spans[i].onclick = function(){
            // console.log(this.index);
            div.className='t'+this.index;         
        }
    }
</script>